using System.Diagnostics;

namespace ThreadingIssues
{
    public class StateObject
    {
        private int _state = 5;

        public void ChangeState(int loop)
        {
            if (_state == 5)
            {
                _state++;

                if (_state != 6)
                {
                    Console.WriteLine($"Race condition occurred after {loop} loops");
                    Trace.Fail($"race condition at {loop}");
                }
            }
            _state = 5;
        }
    }
}
